package com.xyz.dao.logic;

import com.free.ext.mybatis.model.entity.PageResponseModel;
import com.xyz.dao.dao.CCustomerOperLogDao;
import com.xyz.domain.table.CCustomerOperLog;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.Date;
import java.util.List;

@Component
public class CCustomerOperLogLogic {

    @Autowired
    private CCustomerOperLogDao cCustomerOperLogDao;

    public CCustomerOperLog add(CCustomerOperLog cCustomerOperLog){
        return cCustomerOperLogDao.insert(cCustomerOperLog);
    }

    public Integer update(CCustomerOperLog cCustomerOperLog){
        return cCustomerOperLogDao.update(cCustomerOperLog);
    }

    public List<CCustomerOperLog> list(CCustomerOperLog cCustomerOperLog, String orderBy){
        return cCustomerOperLogDao.selectList(cCustomerOperLog, orderBy);
    }

    public Integer delete(Integer key){
        return cCustomerOperLogDao.delete(key);
    }

    public PageResponseModel<CCustomerOperLog> pageInfo(CCustomerOperLog cCustomerOperLog, String orderBy, Integer pageNo, Integer pageSize){
        return cCustomerOperLogDao.selectByPageNo(cCustomerOperLog, orderBy, pageNo, pageSize);
    }

    public CCustomerOperLog addOperInfo(String category, String type, Integer customerId){
        CCustomerOperLog cCustomerOperLog = new CCustomerOperLog();
        cCustomerOperLog.setCategory(category);
        cCustomerOperLog.setType(type);
        cCustomerOperLog.setCustomerId(customerId);
        cCustomerOperLog.setCreateTime(new Date());
        return add(cCustomerOperLog);
    }

}